/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.gft.bancosimulador.views;

import com.gft.bancosimulador.beans.Cliente;
import com.gft.bancosimulador.business.ClienteBusiness;
import com.gft.bancosimulador.outros.Sorteador;
import com.gft.bancosimulador.controller.AlterarClienteController;
import com.gft.bancosimulador.controller.BloquearClienteController;
import com.gft.bancosimulador.controller.CancelarClienteController;
import com.gft.bancosimulador.controller.ConsultarClienteController;
import com.gft.bancosimulador.controller.ReativarClienteController;
import java.awt.Component;
import java.util.Arrays;
import java.util.List;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author AEPI
 */
public class ConsultaView extends javax.swing.JInternalFrame {

    /**
     * Creates new form ConsultaView
     */
    public ConsultaView() {
        initComponents();
    }
    
    private void mostrarClientes(Cliente cliente) {
        this.mostrarClientes(Arrays.asList(cliente));
    }

    private void mostrarClientes(List<Cliente> clientes) {
        int linhas = (clientes == null? 0: clientes.size());
        Object[][] dados = new Object[linhas][];
        for (int i = 0; i < linhas; i++){
            Cliente c = clientes.get(i);
            Object[] linhaDado = new Object[]{
                c.getCodigo(), c.getNome(),c.getCidade(), c.getSituacaoCliente()
            };
            dados[i] = linhaDado;
        }

        String[] nomesColunas = new String[]{
            "Codigo", "Nome", "Cidade", "Estado Cliente"
        };
        DefaultTableModel model = new DefaultTableModel(dados, nomesColunas);
        jTable1.setModel(model);
    }
    
        private Integer getCodigoCliente(){
        Integer codigo = (Integer) jTable1.getModel().getValueAt(jTable1.getSelectedRow(), 0);
        return codigo;
    }

    private void mostrarJanela(Component janela) {
        this.getParent().add(janela);
        janela.setVisible(true);
    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel6 = new javax.swing.JPanel();
        rdbOrdCodigo = new javax.swing.JRadioButton();
        rdbOrdNome = new javax.swing.JRadioButton();
        rdbOrdSobrenome = new javax.swing.JRadioButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        btn_AlterarCliente = new javax.swing.JButton();
        btn_VisualizarCliente = new javax.swing.JButton();
        btn_BloquearCliente = new javax.swing.JButton();
        btn_CancelarCliente = new javax.swing.JButton();
        btn_Reativar = new javax.swing.JButton();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        txt_Codigo = new javax.swing.JTextField();
        btnConsultarCodigo = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        txt_Nome = new javax.swing.JTextField();
        btnConsultarNome = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        btnConsultarCPF = new javax.swing.JButton();
        txt_CPF = new javax.swing.JFormattedTextField();
        jPanel4 = new javax.swing.JPanel();
        btnConsultarCNPJ = new javax.swing.JButton();
        txt_CNPJ = new javax.swing.JFormattedTextField();
        jPanel5 = new javax.swing.JPanel();
        txt_MaximoContemplados = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        btn_SortearClientes = new javax.swing.JButton();
        rbtn_ClientesFisicos = new javax.swing.JRadioButton();
        rbtn_ClientesJuridicos = new javax.swing.JRadioButton();
        rbtn_TodosClientes = new javax.swing.JRadioButton();
        jPanel7 = new javax.swing.JPanel();
        rbtn_CodOrdem = new javax.swing.JRadioButton();
        rbtn_NomeOrdem = new javax.swing.JRadioButton();

        rdbOrdCodigo.setText("Código");
        rdbOrdCodigo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rdbOrdCodigoActionPerformed(evt);
            }
        });

        rdbOrdNome.setText("Nome");
        rdbOrdNome.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rdbOrdNomeActionPerformed(evt);
            }
        });

        rdbOrdSobrenome.setText("Sobrenome/Nome Fantasia");
        rdbOrdSobrenome.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rdbOrdSobrenomeActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(rdbOrdCodigo)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(rdbOrdNome)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(rdbOrdSobrenome)
                .addContainerGap(224, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()
                .addContainerGap(15, Short.MAX_VALUE)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rdbOrdCodigo)
                    .addComponent(rdbOrdNome)
                    .addComponent(rdbOrdSobrenome))
                .addContainerGap())
        );

        setClosable(true);
        setTitle("Consulta Cliente");

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Codigo", "Nome", "Cidade", "Estado Cliente"
            }
        ));
        jTable1.setColumnSelectionAllowed(true);
        jScrollPane1.setViewportView(jTable1);
        jTable1.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);

        btn_AlterarCliente.setText("Alterar");
        btn_AlterarCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_AlterarClienteActionPerformed(evt);
            }
        });

        btn_VisualizarCliente.setText("Visualizar");
        btn_VisualizarCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_VisualizarClienteActionPerformed(evt);
            }
        });

        btn_BloquearCliente.setText("Bloquear");
        btn_BloquearCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_BloquearClienteActionPerformed(evt);
            }
        });

        btn_CancelarCliente.setText("Cancelar");
        btn_CancelarCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_CancelarClienteActionPerformed(evt);
            }
        });

        btn_Reativar.setText("Reativar");
        btn_Reativar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_ReativarActionPerformed(evt);
            }
        });

        btnConsultarCodigo.setText("Consultar");
        btnConsultarCodigo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnConsultarCodigoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(txt_Codigo, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 294, Short.MAX_VALUE)
                .addComponent(btnConsultarCodigo)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txt_Codigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnConsultarCodigo))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Código", jPanel1);

        btnConsultarNome.setText("Consultar");
        btnConsultarNome.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnConsultarNomeActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(txt_Nome, javax.swing.GroupLayout.PREFERRED_SIZE, 270, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 128, Short.MAX_VALUE)
                .addComponent(btnConsultarNome)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txt_Nome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnConsultarNome))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Nome", jPanel2);

        btnConsultarCPF.setText("Consultar");
        btnConsultarCPF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnConsultarCPFActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(txt_CPF, javax.swing.GroupLayout.PREFERRED_SIZE, 222, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 176, Short.MAX_VALUE)
                .addComponent(btnConsultarCPF)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnConsultarCPF)
                    .addComponent(txt_CPF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("CPF", jPanel3);

        btnConsultarCNPJ.setText("Consultar");
        btnConsultarCNPJ.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnConsultarCNPJActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(txt_CNPJ, javax.swing.GroupLayout.PREFERRED_SIZE, 222, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 176, Short.MAX_VALUE)
                .addComponent(btnConsultarCNPJ)
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnConsultarCNPJ)
                    .addComponent(txt_CNPJ, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("CNPJ", jPanel4);

        txt_MaximoContemplados.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txt_MaximoContempladosActionPerformed(evt);
            }
        });

        jLabel1.setText("Máximo Contemplados:");

        btn_SortearClientes.setText("Sortear");
        btn_SortearClientes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_SortearClientesActionPerformed(evt);
            }
        });

        rbtn_ClientesFisicos.setText("Físico");

        rbtn_ClientesJuridicos.setText("Jurídico");

        rbtn_TodosClientes.setSelected(true);
        rbtn_TodosClientes.setText("Todos");

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txt_MaximoContemplados, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(rbtn_ClientesFisicos)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(rbtn_ClientesJuridicos)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(rbtn_TodosClientes)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 83, Short.MAX_VALUE)
                .addComponent(btn_SortearClientes)
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txt_MaximoContemplados, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btn_SortearClientes)
                    .addComponent(rbtn_ClientesFisicos)
                    .addComponent(rbtn_ClientesJuridicos)
                    .addComponent(rbtn_TodosClientes))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Sorteio Clientes", jPanel5);

        rbtn_CodOrdem.setText("Código");
        rbtn_CodOrdem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbtn_CodOrdemActionPerformed(evt);
            }
        });

        rbtn_NomeOrdem.setText("Nome");
        rbtn_NomeOrdem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbtn_NomeOrdemActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(rbtn_CodOrdem)
                .addGap(31, 31, 31)
                .addComponent(rbtn_NomeOrdem)
                .addContainerGap(348, Short.MAX_VALUE))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                .addContainerGap(15, Short.MAX_VALUE)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rbtn_CodOrdem)
                    .addComponent(rbtn_NomeOrdem))
                .addContainerGap())
        );

        jTabbedPane1.addTab("Ordenar Clientes", jPanel7);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(btn_AlterarCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btn_VisualizarCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btn_BloquearCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btn_CancelarCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btn_Reativar, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.Alignment.TRAILING))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 62, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 400, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btn_AlterarCliente)
                    .addComponent(btn_VisualizarCliente)
                    .addComponent(btn_BloquearCliente)
                    .addComponent(btn_CancelarCliente)
                    .addComponent(btn_Reativar))
                .addGap(40, 40, 40))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void rdbOrdCodigoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdbOrdCodigoActionPerformed

    }//GEN-LAST:event_rdbOrdCodigoActionPerformed

    private void rdbOrdNomeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdbOrdNomeActionPerformed

    }//GEN-LAST:event_rdbOrdNomeActionPerformed

    private void rdbOrdSobrenomeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdbOrdSobrenomeActionPerformed

    }//GEN-LAST:event_rdbOrdSobrenomeActionPerformed

    private void btn_ReativarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_ReativarActionPerformed
        // TODO add your handling code here:
        this.mostrarJanela(new ReativarClienteController(this.getCodigoCliente()));
        
    }//GEN-LAST:event_btn_ReativarActionPerformed

    private void btn_CancelarClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_CancelarClienteActionPerformed
        // TODO add your handling code here:
        this.mostrarJanela(new CancelarClienteController(this.getCodigoCliente()));
        
    }//GEN-LAST:event_btn_CancelarClienteActionPerformed

    private void btn_AlterarClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_AlterarClienteActionPerformed
        // TODO add your handling code here:
        this.mostrarJanela(new AlterarClienteController(this.getCodigoCliente()));
        
    }//GEN-LAST:event_btn_AlterarClienteActionPerformed

    private void btnConsultarCodigoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConsultarCodigoActionPerformed
        int codigo = Integer.parseInt(txt_Codigo.getText());
        Cliente cliente = ClienteBusiness.getInstance().
        consultarClientePorCodigo(codigo);
        this.mostrarClientes(cliente);
    }//GEN-LAST:event_btnConsultarCodigoActionPerformed

    private void btnConsultarNomeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConsultarNomeActionPerformed
        String nome = txt_Nome.getText();
        List<Cliente> clientes = ClienteBusiness.getInstance().consultarClientePorNome(nome);
        this.mostrarClientes(clientes);
    }//GEN-LAST:event_btnConsultarNomeActionPerformed

    private void btnConsultarCPFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConsultarCPFActionPerformed
        Cliente c = ClienteBusiness.getInstance().consultarClientePorCpf(txt_CPF.getText());
        this.mostrarClientes(c);
    }//GEN-LAST:event_btnConsultarCPFActionPerformed

    private void btnConsultarCNPJActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConsultarCNPJActionPerformed
        Cliente c = ClienteBusiness.getInstance().consultarClientePorCnpj(txt_CNPJ.getText());
        this.mostrarClientes(c);
    }//GEN-LAST:event_btnConsultarCNPJActionPerformed

    private void txt_MaximoContempladosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txt_MaximoContempladosActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txt_MaximoContempladosActionPerformed

    private void btn_SortearClientesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_SortearClientesActionPerformed

            Sorteador<Cliente> sorteador = new Sorteador<Cliente>();
            int totalPremiados = Integer.parseInt(txt_MaximoContemplados.getText());
            if (rbtn_TodosClientes.isSelected()){
                sorteador.setParticipantes(ClienteBusiness.getInstance().consultarClientePorNome(""));
            } else if (rbtn_ClientesFisicos.isSelected()){
                sorteador.setParticipantes(ClienteBusiness.getInstance().listarClientesFisicos());
            } else if (rbtn_ClientesJuridicos.isSelected()){
                sorteador.setParticipantes(ClienteBusiness.getInstance().listarClientesJuridicos());
            }
            List<Cliente> sorteados = sorteador.sortear(totalPremiados);
            this.mostrarClientes(sorteados);
        
    }//GEN-LAST:event_btn_SortearClientesActionPerformed

    private void rbtn_CodOrdemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbtn_CodOrdemActionPerformed

    }//GEN-LAST:event_rbtn_CodOrdemActionPerformed

    private void rbtn_NomeOrdemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbtn_NomeOrdemActionPerformed

    }//GEN-LAST:event_rbtn_NomeOrdemActionPerformed

    private void btn_BloquearClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_BloquearClienteActionPerformed
        // TODO add your handling code here:
        this.mostrarJanela(new BloquearClienteController(this.getCodigoCliente()));
        
    }//GEN-LAST:event_btn_BloquearClienteActionPerformed

    private void btn_VisualizarClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_VisualizarClienteActionPerformed
        // TODO add your handling code here:
        this.mostrarJanela(new ConsultarClienteController(this.getCodigoCliente()));
        
    }//GEN-LAST:event_btn_VisualizarClienteActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnConsultarCNPJ;
    private javax.swing.JButton btnConsultarCPF;
    private javax.swing.JButton btnConsultarCodigo;
    private javax.swing.JButton btnConsultarNome;
    private javax.swing.JButton btn_AlterarCliente;
    private javax.swing.JButton btn_BloquearCliente;
    private javax.swing.JButton btn_CancelarCliente;
    private javax.swing.JButton btn_Reativar;
    private javax.swing.JButton btn_SortearClientes;
    private javax.swing.JButton btn_VisualizarCliente;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JRadioButton rbtn_ClientesFisicos;
    private javax.swing.JRadioButton rbtn_ClientesJuridicos;
    private javax.swing.JRadioButton rbtn_CodOrdem;
    private javax.swing.JRadioButton rbtn_NomeOrdem;
    private javax.swing.JRadioButton rbtn_TodosClientes;
    private javax.swing.JRadioButton rdbOrdCodigo;
    private javax.swing.JRadioButton rdbOrdNome;
    private javax.swing.JRadioButton rdbOrdSobrenome;
    private javax.swing.JFormattedTextField txt_CNPJ;
    private javax.swing.JFormattedTextField txt_CPF;
    private javax.swing.JTextField txt_Codigo;
    private javax.swing.JTextField txt_MaximoContemplados;
    private javax.swing.JTextField txt_Nome;
    // End of variables declaration//GEN-END:variables
}
